﻿using System.Collections.Generic;
using Caliburn.Micro;

namespace Scrabble.Tasks
{
    public static class Result
    {
        public static IEnumerable<T> AsEnumerable<T>(this T item)
        {
            return new[] { item };
        }

        public static void Execute(this IResult task, ActionExecutionContext context = null)
        {
            task.AsEnumerable().Execute(context);
        }

        public static void Execute(this IEnumerable<IResult> tasks, ActionExecutionContext context = null)
        {
            if (tasks == null) return;
            Coroutine.BeginExecute(tasks.GetEnumerator(), context);
        }
    }
}